<template>
	<view class="page home bgf7 c85">
		<view class="aliC c00 title pb16 rel" :style="{paddingTop: statusBar + 'px'}">代理商端主页</view>

		<scroll-view scroll-y="true" :style="{height: 'calc(100vh - 214rpx - ' + statusBar +'px)'}">
			<view class="bgff mx15 rel r7 pt16 pb24 mt18 shadow">

				<view class="flex flexC rel cff px15">
					<text class="fs14 c00">•</text>
					<text class="px6 c00 bold8">门店统计</text>
				</view>
				<view class="flex flexC flexB aliC mt30">
					<view class="flex1">
						<view class="bold6 fs20 c00">{{data.shopCountMonth}}</view>
						<view class="c85 mt2">本月新增(家)</view>
					</view>
					<view class="flex1 boxS borr borl">
						<view class="bold6 fs20 c00">{{data.shopCountLast}}</view>
						<view class="c85 mt2">上月新增(家)</view>
					</view>
					<view class="flex1">
						<view class="bold6 fs20 c00">{{data.shopCountAll}}</view>
						<view class="c85 mt2">累计数量</view>
					</view>
				</view>
			</view>


			<view class="bgff mx15 rel r7 pt16 pb24 mt18 shadow">

				<view class="flex flexC rel cff px15">
					<text class="fs14 c00">•</text>
					<text class="px6 c00 bold8">收益统计</text>
				</view>
				<view class="flex flexC flexB aliC mt30" @click="clickMore">
					<view class="flex1">
						<view class="bold6 fs20 c00">{{data.monthProfit}}</view>
						<view class="c85 mt2">本月收益(元)</view>
					</view>
					<view class="flex1 boxS borr borl">
						<view class="bold6 fs20 c00">{{data.lastProfit}}</view>
						<view class="c85 mt2">上月收益(元)</view>
					</view>
					<view class="flex1">
						<view class="bold6 fs20 c00">{{data.teamProfit}}</view>
						<view class="c85 mt2">团队收益</view>
					</view>
					<view class="flex1">
						<view class="bold6 fs20 c00">{{data.allProfit}}</view>
						<view class="c85 mt2">总收益</view>
					</view>
				</view>
			</view>





		</scroll-view>

		<view class="flex flexC rel cff px15">
			<text class="fs14">•</text>
			<text class="px6">门店统计</text>
		</view>

		<tabbar></tabbar>
	</view>

</template>

<script>
	const statusBar = uni.getSystemInfoSync().statusBarHeight + 10;
	export default {
		data() {
			return {
				statusBar,
				list: [{
						name: '今天'
					},
					{
						name: '昨天'
					},
					{
						name: '本月'
					}
				],
				totalAmount: 0,
				profit: 0,
				totalOrder: 0,
				shop: 0,
				currentIndex: 1,
				data:null
			}
		},
		onLoad() {
			this.getIndex();
		},
		methods: {
			
			clickMore(){
				uni.navigateTo({
					url:'../agent/more'
				})
			},

			switchTab(e) {
				var name = e.name;
				if (name == '今天') {
					this.currentIndex = 1;
				} else if (name == '昨天') {
					this.currentIndex = 2;
				} else {
					this.currentIndex = 3;
				}
				this.getIndex();
			},

			getIndex() {
				let param = {
					type: this.currentIndex
				};
				let that = this;
				this.$api.getAgentIndex(param).then(res => {

					console.info(JSON.stringify(res));
					if (res.code == 1) {

						that.data = res.data;
					} else {

					}
				})
			}

		}
	}
</script>

<style lang="scss" scoped>
	.home {
		.down {
			width: 36rpx;
			height: 36rpx;
		}

		.bg {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 0;
		}

		.rel {
			position: relative;
		}

		.right {
			width: 14rpx;
		}

		.w36 {
			width: 72rpx;
			height: 72rpx;
		}
	}
</style>